<?php

if((isset($_POST['dt_inicial']) or isset($_POST['dt_final'])) and isset($_POST['tipo_rel']))
{
    include_once 'app.ado/DataBase.php';
    
    $s = new DataBase();
    $db = $s->getConn();
    
    include 'app.functions/formataData.php';
    
    if($_POST['tipo_rel'] == "requisicao")
    {
        $dt_inicial = isset($_POST['dt_inicial']) ? formataData($_POST['dt_inicial']) : '2000-01-01';
        $dt_final = isset($_POST['dt_final']) ? formataData($_POST['dt_final']) : date('Y-m-d');
        
        $sql = 'select * from req_manutencao
where dt_requisicao between ? and ?';
        $sth = $db->prepare($sql);
        
        $sth->execute(array($dt_inicial,$dt_final));
        
        $req = $sth->fetchAll(PDO::FETCH_CLASS, "Requerir");
        
        $rel = new TRelManutencao($req);
        $rel->render();
        
        //header('location: index.php?modulo=manutencoes&page=imprimir');
        //header('location: index.php');
    }
}
?>
